"""
演示文件的写入
"""

# 打开文件，不存在的文件, r, w, a
import time

# 打开一个不存在的文件
f = open("D:/python-learn/test.txt", "w", encoding="UTF-8")
# write写入
f.write("Hello World!!!") # 内容写入到内存中
# flush刷新
f.flush()   # 将内存中积攒的内容，写入到硬盘的文件中
# close关闭
f.close()   # close方法，内置了flush的功能的

# 打开一个存在的文件
# w 会清空文件原有的内容
f = open("D:/python-learn/test.txt", "w", encoding="UTF-8")
# write写入、flush刷新
f.write("I am an atheist and that's it. I believe there's nothing we can know except that we should be kind to each other and do what we can for other people.")
# close关闭
f.close()